package com.ruoyi.web.until;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.RandomUtil;

import java.util.Random;

public class Base64utils {
    public static String encryptions  (String str){
        String str1 = randSix()+str;
        System.out.println(str1);
        return Base64.encode(str1);
    }

    public static String randSix(){
        String []baseStr = {"1","2","3","4","5","6","7","8","9","0",
                "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","A","B"};
        String str="";
        for(int i = 0 ;i<6;i++){
            int index = ((int)(100*Math.random()))%baseStr.length;
            str += baseStr[index];
        }
        return str;
    }

    public static String decrypts  (String str){
        String str1 = Base64.decodeStr(str);
        Integer s = str1.length();
        return str1.substring(6,s);
    }
}
